{% extends "base.html" %}
{% block title %}添加文章{% endblock %}
{% block style %}
     <script type="text/javascript" src='/static/js/wangEditor.min.js'></script>
{% endblock %}
{% block body1 %}{% include "nav.html" %} {% endblock %}
{% block bodyside %}{% endblock %}
{% block bodymain %}
<br>标题：<div contenteditable="true" style="border:1px solid #000;width:150px;height:25px" id="title" ></div><br>
<br>正文：<br><div id="content" ></div><br>
<button  id="sumbit">提交</button>
{% endblock %}
{% block script %}<script type="text/javascript">
$(document).ready(function(){
	var E = window.wangEditor;
	var editor = new E('#content');
	editor.create();
	$('#sumbit').click(function(){
		var title= $('#title').html();
		 var content =editor.txt.html();
		 var temptopic=editor.txt.text();
		 var topic=temptopic.substr(0,199);
         var blog={'title':title,'content':content,'topic':topic};
		$.post("/blogpost",blog,function(data,status){
					window.location.href = "/blogindex";
		});
	});
});
$.ajaxSetup({headers: {"X-CSRFToken": '{{ csrf_token }}'}});
</script>{% endblock %}